<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- include libraries(jQuery, bootstrap) -->
<link rel="stylesheet" href="/plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
<script src="/plugins/jquery/jquery-3.2.1.min.js"></script>
<script src="/plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!-- 官网bootstrap css和js是3.3.5暂时用3.3.7有问题在换 -->
<!-- <script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>-->
<!-- include summernote css/js-->
<link href="/plugins/summernote/summernote.css" rel="stylesheet">
<script src="/plugins/summernote/summernote.min.js"></script>
<script type="text/javascript" src="/plugins/summernote/lang/summernote-zh-CN.js"></script>
</head>
<body>
	<div id="summernote"></div>

</body>
<script type="text/javascript">
	$(document).ready(function() {
		$('#summernote').summernote({
			lang : 'zh-CN',
			height : 300,
			placeholder : 'hello summernote !',
			width : 1000,
			minHeight : null,
			maxHeight : null,
			focus : true,
			callbacks : {
				/* 	onInit : function() {
						console.log('Summernote is launched');
					},
					onFocus : function() {
						console.log('Editable area is focused');
					},
					onKeyup : function(e) {
						console.log('Key is released:', e.keyCode);
					},
					onPaste : function(e) {
						console.log('Called event paste');
					}, */
				onImageUpload : function(files) {
					sendFile(files);
				}
			}
		});
	});

	function sendFile(files) {
		var data = new FormData();
		data.type = 3;
		data.append("file", files[0]);
		$.ajax({
			data : data,
			type : "POST",
			url : '/common/summernote',
			cache : false,
			contentType : false,
			processData : false,
			dataType : "json",
			success : function(data) {
				$('#summernote').summernote('insertImage', data.path);
			},
			error : function() {
				alert("上传失败");
			}
		});
	}
</script>
</html>